import 'package:flutter_nb_net/flutter_net.dart';

class TrackResp extends BaseNetModel {
  int? code;
  String? msg;
  List<TrackData>? data;

  TrackResp({
    this.code,
    this.msg,
    this.data,
  });

  @override
  fromJson(Map<String, dynamic> json) {
    return TrackResp(
      code: json["code"],
      msg: json["msg"],
      data: json["data"] == null ? null : List<TrackData>.from(json["data"].map((x) => TrackData().fromJson(x))),
    );
  }

}

class TrackData extends BaseNetModel {
  String? gpsDataId;
  double? latitude;
  double? longitude;
  int? altitude;
  double? speed;
  int? direction;
  String? directionName;
  String? dateTime;
  String? locationTime;
  int? locationType;
  String? locationDesc;
  Mercator? mercator;
  int? acc;
  bool? holdPoint;
  num? residenceTime;
  String? residenceStartTime;
  String? residenceEndTime;

  TrackData({
    this.gpsDataId,
    this.latitude,
    this.longitude,
    this.altitude,
    this.speed,
    this.direction,
    this.directionName,
    this.dateTime,
    this.locationTime,
    this.locationType,
    this.locationDesc,
    this.mercator,
    this.acc,
    this.holdPoint,
    this.residenceTime,
    this.residenceStartTime,
    this.residenceEndTime,
  });

  @override
  fromJson(Map<String, dynamic> json) {
    return TrackData(
      gpsDataId: json["gpsDataId"],
      latitude: json["latitude"],
      longitude: json["longitude"],
      altitude: json["altitude"],
      speed: json["speed"],
      direction: json["direction"],
      directionName: json["directionName"],
      dateTime: json["dateTime"],
      locationTime: json["locationTime"],
      locationType: json["locationType"],
      locationDesc: json["locationDesc"],
      mercator: json["mercator"] == null ? null : Mercator().fromJson(json["mercator"]),
      acc: json["acc"],
      holdPoint: json["holdPoint"],
      residenceTime: json["residenceTime"],
      residenceStartTime: json["residenceStartTime"],
      residenceEndTime: json["residenceEndTime"],
    );
  }

  copyWith({required double latitude, required double longitude, bool holdPoint = false, String? gpsDataId}) {
    return TrackData(
      gpsDataId: gpsDataId,
      latitude: latitude,
      longitude: longitude,
      altitude: this.altitude,
      speed: this.speed,
      direction: this.direction,
      directionName: this.directionName,
      dateTime: this.dateTime,
      locationTime: this.locationTime,
      locationType: this.locationType,
      locationDesc: this.locationDesc,
      mercator: this.mercator,
      acc: this.acc,
      holdPoint: holdPoint,
      residenceTime: this.residenceTime,
      residenceStartTime: this.residenceStartTime,
      residenceEndTime: this.residenceEndTime,
    );
  }

}

class Mercator extends BaseNetModel {
  double? x;
  double? y;

  Mercator({
    this.x,
    this.y,
  });

  @override
  fromJson(Map<String, dynamic> json) {
    return Mercator(
      x: json["x"],
      y: json["y"],
    );
  }
}